package com.mask.im.business.common.util;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.mask.im.business.model.dto.MobileDTO;
import com.mask.im.business.common.constant.CommonConstant;
import lombok.extern.slf4j.Slf4j;

/**
 * 短信发送工具类
 */
@Slf4j
public class SMSUtil {

	/**
	 * 发送短信
	 * @param mobileDTO
	 */
	public static void sendMessage(MobileDTO mobileDTO){
		DefaultProfile profile = DefaultProfile.getProfile("cn-chongqing", "LTAI5t7SguwWAMn4uptAZbXz", "mMJF5YoDSxzCzJDAzrV62zqekP2TuD");
		IAcsClient client = new DefaultAcsClient(profile);

		SendSmsRequest request = new SendSmsRequest();
		request.setSysRegionId("cn-chongqing");
		request.setPhoneNumbers(mobileDTO.getMobile());
		request.setSignName(CommonConstant.ALY_SIGNNAME);
		request.setTemplateCode(CommonConstant.ALY_TEMPLATECODE);
		request.setTemplateParam("{\"code\":\""+mobileDTO.getCode()+"\"}");
		try {
			SendSmsResponse response = client.getAcsResponse(request);
		}catch (ClientException e) {
			e.printStackTrace();
		}
	}

}
